/**
 * 项目名：phms3
 * 日期：    2019-12-01 17:02:29
 * Copyright (c) 2015- HTSC-版权所有
 */

package com.joysuch.wwyt.bp.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import com.joysuch.wwyt.mh.entity.MhMonitoringPoint;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.hibernate.annotations.WhereJoinTable;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "WWYT_BP_DEVICE_FACILITY_COLLECTION")
@SQLDelete(sql = "update WWYT_BP_DEVICE_FACILITY_COLLECTION set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update WWYT_BP_DEVICE_FACILITY_COLLECTION set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")

public class BpDeviceFacilityCollection implements java.io.Serializable {

    // columns START
    // ID
    private java.lang.Long id;
    // 租户
    private java.lang.Long tenentId;
    // 设备类型
    private java.lang.Long deviceTypeId;
    // 设备类型名称
    private java.lang.String deviceTypeName;
    // 设备ID
    private java.lang.Long deviceId;
    // 编号
    private java.lang.String code;
    // 名称
    private java.lang.String name;
    // 子类型
    private java.lang.String subType;
    // 所在区域
    private java.lang.Long districtId;
    // 所在区域名称
    private java.lang.String districtName;
    // 创建人
    private java.lang.Long createBy;
    // 创建时间
    private java.util.Date createTime;
    // 更新人
    private java.lang.Long updateBy;
    // 更新时间
    private java.util.Date updateTime;
    // 删除标记
    private java.lang.String deleteFlag;
    // 组织机构代码
    private java.lang.String orgCode;
    // columns END
    // 是否关键装置
    private String keyEquipment;

    private Long majorHazardId;

    private String coordinates;

    public void setId(java.lang.Long value) {
        this.id = value;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "Id", unique = true, nullable = false)
    public java.lang.Long getId() {
        return this.id;
    }

    @Column(name = "TENENT_ID")
    public java.lang.Long getTenentId() {
        return this.tenentId;
    }

    public void setTenentId(java.lang.Long value) {
        this.tenentId = value;
    }

    @Column(name = "DEVICE_TYPE_ID", nullable = false)
    public java.lang.Long getDeviceTypeId() {
        return this.deviceTypeId;
    }

    public void setDeviceTypeId(java.lang.Long value) {
        this.deviceTypeId = value;
    }

    @Column(name = "DEVICE_TYPE_NAME", length = 20)
    public java.lang.String getDeviceTypeName() {
        return this.deviceTypeName;
    }

    public void setDeviceTypeName(java.lang.String value) {
        this.deviceTypeName = value;
    }

    @Column(name = "DEVICE_ID")
    public java.lang.Long getDeviceId() {
        return this.deviceId;
    }

    public void setDeviceId(java.lang.Long value) {
        this.deviceId = value;
    }

    @Column(name = "CODE", length = 30)
    public java.lang.String getCode() {
        return this.code;
    }

    public void setCode(java.lang.String value) {
        this.code = value;
    }

    @Column(name = "NAME", length = 50)
    public java.lang.String getName() {
        return this.name;
    }

    public void setName(java.lang.String value) {
        this.name = value;
    }

    @Column(name = "SUB_TYPE", length = 10)
    public java.lang.String getSubType() {
        return this.subType;
    }

    public void setSubType(java.lang.String value) {
        this.subType = value;
    }

    @Column(name = "DISTRICT_ID")
    public java.lang.Long getDistrictId() {
        return this.districtId;
    }

    public void setDistrictId(java.lang.Long value) {
        this.districtId = value;
    }

    @Column(name = "DISTRICT_NAME", length = 50)
    public java.lang.String getDistrictName() {
        return this.districtName;
    }

    public void setDistrictName(java.lang.String value) {
        this.districtName = value;
    }

    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    public java.lang.Long getCreateBy() {
        return this.createBy;
    }

    public void setCreateBy(java.lang.Long value) {
        this.createBy = value;
    }

    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    public java.util.Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(java.util.Date value) {
        this.createTime = value;
    }

    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    public java.lang.Long getUpdateBy() {
        return this.updateBy;
    }

    public void setUpdateBy(java.lang.Long value) {
        this.updateBy = value;
    }

    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    public java.util.Date getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(java.util.Date value) {
        this.updateTime = value;
    }

    @Column(name = "DELETE_FLAG", length = 2)
    public java.lang.String getDeleteFlag() {
        return this.deleteFlag;
    }

    public void setDeleteFlag(java.lang.String value) {
        this.deleteFlag = value;
    }

    @Column(name = "ORG_CODE", length = 100)
    public java.lang.String getOrgCode() {
        return this.orgCode;
    }

    public void setOrgCode(java.lang.String value) {
        this.orgCode = value;
    }

    @Column(name = "KEY_EQUIPMENT", length = 2)
    public String getKeyEquipment() {
        return this.keyEquipment;
    }

    public void setKeyEquipment(String value) {
        this.keyEquipment = value;
    }

    @Column(name = "MAJOR_HAZARD_ID")
    public Long getMajorHazardId() {
        return majorHazardId;
    }

    public void setMajorHazardId(Long majorHazardId) {
        this.majorHazardId = majorHazardId;
    }

    @Column(name = "COORDINATES", length = 1000)
    public String getCoordinates() {
        return coordinates;
    }

    public void setCoordinates(String coordinates) {
        this.coordinates = coordinates;
    }

    private Set<MhMonitoringPoint> mhMonitoringPoints = new LinkedHashSet<>(0);

    @ManyToMany(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
    @WhereJoinTable(clause = " DELETE_FLAG='0' ")
    @JoinTable(name = "WWYT_BP_DEVICE_FACILITY_MONITORING_POINT", joinColumns = @JoinColumn(name = "DEVICE_ID"), inverseJoinColumns = @JoinColumn(name = "MONITORING_POINT_ID"))
    public Set<MhMonitoringPoint> getMhMonitoringPoints() {
        return this.mhMonitoringPoints;
    }

    public void setMhMonitoringPoints(Set<MhMonitoringPoint> mhMonitoringPoints) {
        this.mhMonitoringPoints = mhMonitoringPoints;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId())
                .append("tenentId", getTenentId()).append("deviceTypeId", getDeviceTypeId())
                .append("deviceTypeName", getDeviceTypeName()).append("deviceId", getDeviceId())
                .append("code", getCode()).append("name", getName()).append("subType", getSubType())
                .append("districtId", getDistrictId()).append("districtName", getDistrictName())
                .append("createBy", getCreateBy()).append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy()).append("updateTime", getUpdateTime())
                .append("deleteFlag", getDeleteFlag()).append("orgCode", getOrgCode())
                .append("keyEquipment", getKeyEquipment()).toString();

    }

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof BpDeviceFacilityCollection == false)
            return false;
        if (this == obj)
            return true;
        BpDeviceFacilityCollection other = (BpDeviceFacilityCollection) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
